﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<OGS.Web.Models.Admin.UserListModel>" %>

<%@ Import Namespace="MvcPaging" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    <%= OGS.Utility.Helper.GetPageTitle("User List") %>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">


    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <ol class="breadcrumb">
                    <li><a href="/admin/manage-dashboard">Home</a></li>
                    <li class="active">User List</li>
                </ol>
            </div>
            <div class="col-xs-12">
                <div class="well well-White">
                    <form name="UserList">
                        <div class="bs-example form-horizontal">
                            <div class="form-group">
                                <div class="col-xs-8">
                                    <%: Html.TextBoxFor(m => m.Search1, new { @class = "form-control", @maxlength = "1000", id = "Search1" , PlaceHolder = "Type to search Username, Email, Name, Shopname, Phone" })%>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-xs-8">
                                    <%: Html.TextBoxFor(m => m.Search2, new { @class = "form-control", @maxlength = "1000", id = "Search2" , PlaceHolder = "Type to search Address, Zip,Area, City, State" })%>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-xs-8">
                                    <%: Html.TextBoxFor(m => m.Search3, new { @class = "form-control", @maxlength = "1000", id = "Search3" , PlaceHolder = "Type to search Bank Accound Name, Account Number" })%>
                                </div>
                            </div>
                            <div class="form-group">
                                <%: Html.LabelFor(m => m.RoleID, new { @class="col-lg-3 control-label" })%>
                                <div class="col-lg-9">
                                    <%: Html.DropDownListFor(m => m.RoleID, new SelectList(Model.Role, "RoleID", "Name"), new { @class = "form-control" , id = "RoleID" })%>
                                    <%: Html.ValidationMessageFor(m => m.RoleID) %>
                                </div>
                            </div>
                            <div class="form-group">
                                <span>&nbsp;&nbsp;&nbsp;</span>
                                <input type="submit" class="btn btn-primary" value="Search" />
                                <%--<a class="btn btn-primary btnSearch">Search</a>--%>
                            </div>
                            <div class="form-group">
                                <div class="col-xs-8" style="padding-top: 14px;">
                                    <%= OGS.Utility.Helper.GetResultCount(Model.SearchAttributes) %>
                                </div>
                                <div class="col-xs-4" style="text-align: right;">
                                    <a href="/admin/save-user" class="btn btn-primary">Add New</a>
                                </div>
                            </div>
                        </div>
                    </form>
                    <div class="table-responsive">
                        <table class="table table-bordered table-striped dataTable">
                            <thead>
                                <%= OGS.Utility.Helper.RenderHeader("User Name", true, "", 0) %>
                                <%= OGS.Utility.Helper.RenderHeader("Name", true, "", 1) %>
                                <%= OGS.Utility.Helper.RenderHeader("Email", true, "", 2) %>
                                <%= OGS.Utility.Helper.RenderHeader("Shopname", true, "", 3) %>
                                <%= OGS.Utility.Helper.RenderHeader("Phone", true, "", 4) %>
                                <%= OGS.Utility.Helper.RenderHeader("Zip", true, "", 5) %>
                                <%= OGS.Utility.Helper.RenderHeader("Social User", true, "", 6) %>
                                <%= OGS.Utility.Helper.RenderHeader("Registerred", true, "", 7) %>
                                <%= OGS.Utility.Helper.RenderHeader("Active", true, "60px", 8) %>
                                <%= OGS.Utility.Helper.RenderHeader("Blocked", true, "", 9) %>
                                <%= OGS.Utility.Helper.RenderHeader("", false, "20px", 5) %>
                            </thead>
                            <tbody>
                                <% if (Model.Users.Count > 0)
                                   {
                                       foreach (var item in Model.Users)
                                       { %>
                                <tr>
                                    <td><%= item.UserName %></td>
                                    <td><%= item.Name %></td>
                                    <td><%= item.Email %></td>
                                    <td><%= item.ShopName %></td>
                                    <td><%= item.Phone %></td>
                                    <td><%= item.Zip %></td>
                                    <td>
                                        <% if (item.IsSocial)
                                           { %>
                                        <span class="glyphicon glyphicon-ok text-success" title="Active"></span>
                                        <% }
                                           else
                                           { %>
                                        <span class="glyphicon glyphicon-remove text-danger" title="Inactive"></span>
                                        <% } %>
                                    </td>
                                    <td>
                                        <% if (item.IsRegSuccess)
                                           { %>
                                        <span class="glyphicon glyphicon-ok text-success" title="Active"></span>
                                        <% }
                                           else
                                           { %>
                                        <span class="glyphicon glyphicon-remove text-danger" title="Inactive"></span>
                                        <% } %>
                                    </td>
                                    <td>
                                        <% if (item.IsActive)
                                           { %>
                                        <span class="glyphicon glyphicon-ok text-success" title="Active"></span>
                                        <% }
                                           else
                                           { %>
                                        <span class="glyphicon glyphicon-remove text-danger" title="Inactive"></span>
                                        <% } %>
                                    </td>
                                    <td>
                                        <% if (item.IsBlocked)
                                           { %>
                                        <span class="glyphicon glyphicon-ok text-success" title="Active"></span>
                                        <% }
                                           else
                                           { %>
                                        <span class="glyphicon glyphicon-remove text-danger" title="Inactive"></span>
                                        <% } %>
                                    </td>

                                    <td><a href="/admin/save-user/<%= item.UserID %>" title="Edit"><i class="fa fa-edit"></i></a></td>
                                </tr>
                                <%      }
                                   }
                                   else
                                   {
                                %>
                                <tr>
                                    <td colspan="6" style="text-align: center;">No results found.</td>
                                </tr>
                                <%      
                                   }
                                %>
                            </tbody>
                        </table>
                    </div>
                    <% if (Model.SearchAttributes.TotalRecordCount > Model.SearchAttributes.RecordsPerPage)
                       { %>
                    <div class="row">
                        <div class="text-center">
                            <%: @Html.Pager(Model.SearchAttributes.RecordsPerPage, Model.SearchAttributes.CurrentPageNumber, Model.SearchAttributes.TotalRecordCount).Options(o =>  o.DisplayTemplate("BootstrapPagination")).Options(o => o.AddRouteValue("name",Model.Search1)) %>
                        </div>
                    </div>
                    <% } %>
                </div>
            </div>
        </div>
    </section>

    <script type="text/javascript">
        $(document).ready(function () {
            $(".btnSearch").click(function () {
                var name = $.trim($("#Name").val());
                //if (name != "") {
                //    location.href = "/admin/user-list/?name=" + $("#Name").val();
                //} else {
                //    location.href = "/admin/user-list/";
                //}
            });

            $("#Name").keypress(function (e) {
                if (e.which == "13") {
                    e.preventDefault();
                    //$(".btnSearch").click();
                }
            });
        });
    </script>

</asp:Content>
